<template>
	<view class="dateils">
		<!--商品图-->
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="(item,index) in swiperList" :key="index">
				<view class="swiper-item">
					<image class="swiper-img" :src="item.imgUrl"></image>
				</view>
			</swiper-item>
		</swiper>
		<!--价格名称-->
		<view class="dateils-goods">
			<view class="goods-pprice">￥399</view>
			<view class="goods-oprice">￥599</view>
			<view class="goods-name">商品名称</view>
		</view>
		<!--商品详情-->
		<view>
			<view>
				<image class="deteils-img" src="../../static/img/commodity1.jpg"></image>
			</view>
			<view>
				<image class="deteils-img" src="../../static/img/commodity1.jpg"></image>
			</view>
			<view>
				<image class="deteils-img" src="../../static/img/commodity1.jpg"></image>
			</view>
			<view>
				<image class="deteils-img" src="../../static/img/commodity1.jpg"></image>
			</view>
			<view>
				<image class="deteils-img" src="../../static/img/commodity1.jpg"></image>
			</view>
		</view>
		<!--商品列表-->
		<Card cardTitle="标题"></Card>
		<CommodityList :dataCommodityList="dataCommodityList"></CommodityList>
		<!--底部-->
		<view class="dateils-foot">
			<view><i class="fa fa-commenting-o"></i></view>
			<view><i class="fa fa-shopping-cart"></i></view>
			<view class="add-shopcart" @tap="showPop()">加入购物车</view>
			<view class="purchase" @tap="showPop()">立即购买</view>
		</view>
		<!--弹出层-->
		<view class="pop" v-show="isShow" @touchmove.stop.prevent="">
			<!--遮掩层-->
			<view class="pop-mask" @tap="hidePop()"></view>
			<!--内容块-->
			<view class="pop-box" :animation="animationData">
				<view>
					<image class="pop-img" src="../../static/img/commodity2.jpg"></image>
				</view>
				<view class="pop-number">
					<view>购买数量</view>
					<UniNumberBox :min="UniNumberBox.min"></UniNumberBox>
				</view>
				<view class="pop-sub">
					确定
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Card from '@/components/common/Card.vue';
	import CommodityList from '@/components/common/CommodityList.vue';
	import UniNumberBox from '@/components/uni/uni-number-box/components/uni-number-box/uni-number-box.vue';
	export default {
		data() {
			return {
				isShow: false,
				animationData: {},
				UniNumberBox: {
					min: 1
				},
				dataCommodityList: [
					{
						id: 1,
						imgUrl: "../../static/img/commodity1.jpg",
						name: "绒毛大衣2022火爆款",
						pprice: "299",
						oprice: "999",
						discount: "5.2"
					},
					{
						id: 2,
						imgUrl: "../../static/img/commodity2.jpg",
						name: "绒毛大衣2022火爆款",
						pprice: "299",
						oprice: "999",
						discount: "5.2"
					},
					{
						id: 3,
						imgUrl: "../../static/img/commodity3.jpg",
						name: "绒毛大衣2022火爆款",
						pprice: "299",
						oprice: "999",
						discount: "5.2"
					},
				],
				swiperList: [
					{
						imgUrl: "../../static/img/commodity1.jpg"
					},
					{
						imgUrl: "../../static/img/commodity1.jpg"
					},
					{
						imgUrl: "../../static/img/commodity1.jpg"
					},
					{
						imgUrl: "../../static/img/commodity1.jpg"
					},
					{
						imgUrl: "../../static/img/commodity1.jpg"
					},
				]
			}
		},
		components: {
			Card,
			CommodityList,
			UniNumberBox
		},
		//修改默认返回
		onBackPress(){
			if(this.isShow){
				this.hidePop();
				return true;
			}
		},
		//点击分享
		onNavigationBarButtonTap(e){
			if(e.type === "share"){
				uni.share({
					"provider": "qq",
					"type": 0,
					"title": "商品标题",
					"href": "http://192.168.1.4:8080/#/pages/details/details",
					"success": function(res){
						uni.showTabBar({
							title: "分享成功"
						})
					},
					fail: function(err){
						console.log(err);
					}
					
				})
			}
		},
		methods: {
			showPop(){
				let animation = uni.createAnimation({
					duration: 200
				})
				animation.translateY(600).step(); 
				this.animationData = animation.export(); 
				this.isShow = true; 
				setTimeout(() => {
					animation.translateY(0).step();
					this.animationData = animation.export(); 
				},200)
			},
			hidePop(){
				let animation = uni.createAnimation({
					duration: 200
				})
				animation.translateY(600).step(); 
				this.animationData = animation.export(); 
				this.isShow = false; 
				setTimeout(() => {
					animation.translateY(0).step();
					this.animationData = animation.export(); 
				},200)
			}
		}
	}
</script>

<style scoped>
.dateils{
	padding-bottom: 90rpx;
}
swiper{
	width: 100%;
	height: 700rpx;
}
.swiper-img{
	width: 100%;
	height: 700rpx;
}
.dateils-goods{
	text-align: center;
	font-weight: bold;
	font-size: 36rpx;
	padding: 10rpx 0;
}
.deteils-img{
	width: 100%;
	height: 700rpx;
}
.dateils-foot{
	position: fixed;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 90rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: #FFFFFF;
}
.dateils-foot .fa{
	width: 60rpx;
	height: 60rpx;
	line-height: 60rpx;
	border-radius: 100%;
	background-color: #000000;
	color: #FFFFFF;
	text-align: center;
	margin: 0 10rpx;
}
.add-shopcart{
	margin: 0 20rpx;
	padding: 16rpx 30rpx;
	background-color: #000000;
	color: #FFFFFF;
	border-radius: 40rpx;
	font-size: 28rpx;
}
.purchase{
	margin: 0 20rpx;
	padding: 16rpx 30rpx;
	background-color: #49BDFB;
	color: #FFFFFF;
	border-radius: 40rpx;
	font-size: 28rpx;
}
.pop{
	position: fixed;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	z-index: 9999;
}
.pop-mask{
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.3);
}
.pop-box{
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	background-color: #FFFFFF;
}
.pop-img{
	width: 260rpx;
	height: 260rpx;
}
.pop-number{
	display: flex;
	justify-content: space-between;
	padding: 20rpx;
}
.pop-sub{
	line-height: 80rpx;
	background-color: #49BDFB;
	color: #FFFFFF;
	text-align: center;
}
</style>
